<?php
/**
 *
 * @author jigal
 *
 */
class Zend_View_Helper_AuthInfo extends Zend_View_Helper_Abstract{
	/**
	 *
	 * @var unknown_type
	 */
	protected $_authService;
	/**
	 *
	 * @param $info
	 * @return unknown_type
	 */
	public function authInfo($info = null){
		if(null === $this->_authService){
			$this->_authService = new EventManager_Service_Authentication();
		}
		if(null === $info){
			return $this;
		}
		if(false === $this->loggedIn()){
			return null;
		}
		return $this->_authService->getIdentity()->$info;
	}
	/**
	 *
	 * @return unknown_type
	 */
	public function isLoggedIn(){
		return $this->_authService->getAuth()->hasIdentity();
	}
	
	public function isAdmin(){
		return ($this->_authService->getAuth()->getStorage()->read()->usr_role == 'admin') ? true : false;
	}

}